<template>
  <div>
    <div class="publish_body">
        <el-form :model="publish_info" label-width="100px" class="publish_form">
            <el-form-item label="分类" style="margin-top: 20px">
                <el-select v-model="publish_info.my_type" placeholder="请选择分类">
                  <el-option v-for="(item,key) in options" :key="key"
                    :label="item.label" :value="item.value"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="项目发起人" style="margin-top: 20px">
                <el-input v-model="publish_info.sponsor" placeholder="请输入发起人名称"></el-input>
            </el-form-item>
            <el-form-item label="身份证号码">
                <el-input v-model="publish_info.identity_number" placeholder="请输入身份证号码以便审核"></el-input>
            </el-form-item>
            <el-form-item label="工作地点">
                <el-input v-model="publish_info.work_address" placeholder="请输入工作地点"></el-input>
            </el-form-item>
            <el-form-item label="工作类型">
                <el-input v-model="publish_info.kind" placeholder="请输入工作类型"></el-input>
            </el-form-item>
            <el-form-item label="工作时长">
                <el-input v-model="publish_info.duration" placeholder="请输入工作时长"></el-input>
            </el-form-item>
            <el-form-item label="工资">
                <el-input v-model="publish_info.salary" placeholder="请输入工资"></el-input>
            </el-form-item>
            <el-form-item label="所需人数">
                <el-input v-model="publish_info.need_number" placeholder="请输入所需人数"></el-input>
            </el-form-item>
            <el-form-item label="工作简介">
                <el-input v-model="publish_info.introduction" placeholder="请输入工作介绍以及对工作人员的要求或应聘条件" type="textarea"></el-input>
            </el-form-item>
            <el-form-item class="btns">
                <el-button @click="publishInfo">提交</el-button>
                <el-button type="primary" @click="back">返回</el-button>
            </el-form-item>
        </el-form>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      options: [{
        value: '0',
        label: '本地就业信息'
      },
      {
        value: '1',
        label: '创业合伙人'
      }],
      publish_info: {
        id: 0,
        uid: window.sessionStorage.getItem('uid'),
        my_type: '',
        sponsor: '',
        identity_number: '',
        work_address: '',
        kind: '',
        duration: '',
        salary: '',
        need_number: '',
        introduction: '',
        is_pass: 0
      }
    }
  },
  methods: {
    back () {
      this.$router.go(-1)
    },
    publishInfo () {
      var token = sessionStorage.getItem('token')
      this.$axios.defaults.headers.Authorization = 'Bearer ' + token
      this.$axios.post('/publishInfo/publish', this.publish_info).then(response => {
        if (response.data.code === '201') this.$message.error('发布失败,请重新发布')
        else if (response.data.code === '200') this.$message.success('发布成功!')
      })
    }
  }
}
</script>

<style lang="less" scoped>
.publish_body{
    width: 800px;
    border-radius: 3px;
    position: absolute;
    left: 50%;
    top: 50px;
    transform: translate(-50%,-50%);
    display: inline;
}
.publish_form{
    position: absolute;
    width: 100%;
    top: 0px;
    padding: 0 20px;
    box-sizing: border-box;
    background-color: white;
}
.btns{
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
    margin-bottom: 40px;
}
</style>
